package mysql

import (
	"fmt"
_ "github.com/go-sql-driver/mysql"
 "github.com/jmoiron/sqlx"
)

type Person struct {
	UserId   int    `db:"user_id"`
	Username string `db:"username"`
	Sex      string `db:"sex"`
	Email    string `db:"email"`
}

type Place struct {
	Country string `db:"country"`
	City    string `db:"city"`
	TelCode int    `db:"telcode"`
}


func insert(db *sqlx.DB) error{

	r, err := db.Exec("insert into person(username, sex, email)values(?, ?, ?)", "wangyu1", "man", "wangyu1@qq.com")
	if err != nil {
		fmt.Println("exec failed, ", err)
		return err
	}
	id, err := r.LastInsertId()
	if err != nil {
		fmt.Println("exec failed, ", err)
		return err
	}

	fmt.Println("insert succ:", id)
	return nil
}
